package com.webank.wedatasphere.linkis.metadata.hive.config;

import com.webank.wedatasphere.linkis.metadata.hive.dao.HiveMetaDao;
import com.webank.wedatasphere.linkis.metadata.service.DataSourceTypeService;
import com.webank.wedatasphere.linkis.metadata.service.impl.DataSourceGpServiceImpl;
import com.webank.wedatasphere.linkis.metadata.service.impl.DataSourceHiveServiceImpl;
import com.webank.wedatasphere.linkis.metadata.util.DbServiceTypeFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName: FactoryConfig
 * @Description: 描述
 * @author: zys
 * @date: 2021/3/3  14:48
 */
@Configuration
public class FactoryConfig {
    @Resource
    DataSourceHiveServiceImpl hiveService;
    @Resource
    DataSourceGpServiceImpl gpService;
    @Bean("dbServiceTypeFactory")
    public DbServiceTypeFactory createDataSourceTypeService(){
        DbServiceTypeFactory dbServiceTypeFactory=new DbServiceTypeFactory();
        Map<String,DataSourceTypeService> service=new HashMap<>();
        //服务加入工厂
        service.put("hive",hiveService);
        service.put("mpp",gpService);
        dbServiceTypeFactory.setDbType(service);
        return dbServiceTypeFactory;
    }
}
